package com.example.jjyu.service.impl;

import com.example.jjyu.entity.Coupon;
import com.example.jjyu.service.CouponService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CouponServiceImpl implements CouponService {

    @Override
    public Coupon autoApplyCoupon(String userId, String platform, Double cartAmount) {
        // 假设一个简单的逻辑，根据金额返回一个优惠券
        if (cartAmount > 50) {
            Coupon coupon = new Coupon();
            coupon.setCouponId("12345");
            coupon.setPlatform(platform);
            coupon.setDiscountAmount(15.0);
            return coupon;
        }
        return null;
    }

    @Override
    public List<Coupon> getExpiringCoupons(String userId) {
        // 模拟即将过期的优惠券
        List<Coupon> coupons = new ArrayList<>();
        Coupon coupon1 = new Coupon("12345", "eleme", 10.0, "2024-09-15");
        Coupon coupon2 = new Coupon("67890", "meituan", 20.0, "2024-09-17");
        coupons.add(coupon1);
        coupons.add(coupon2);
        return coupons;
    }
}